

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script type="text/javascript" src="helpman_topicinit.js"></script>

<title>Script Editor [Enterprise Architect User Guide]</title>

<meta name="keywords" content="Enterprise Architect, Sparx Systems, UML, Scripter Window,Scripter Window Script Editor,Scripter Window Editor,Scripter Window Script Objects,Scripter Window Type Libraries,Scripter Window Runtime Objects,Scripter Window Intellisense,Intellisense,Intellisense In Script Editor,Intellisense Keystrokes, Script Editor,Script Objects,Type Libraries,Type Libraries For Script Editor,Runtime Object,Runtime Object In Script Editor">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />

<link type="text/css" href="default.css" rel="stylesheet" />
<style type="text/css">
  A, A:Visited
  {
    color: #00F;
  }

  A:Active, A:Hover
  {
    color: #F00;
  }

  OL
  {
    margin: 5px 0 5px 48px;
  }

  UL
  {
    margin-bottom: 3px;
    margin-top: 0;
  }

  #nsr
  {
    background-color: #D4DFFF;
  }

  #nsr A
  {
    text-decoration: none;
  }

  #mainbody
  {
    padding: 8px;
  }

  .p_BodyText
  {
    padding: 5px 0;
  }
</style>



<style type="text/css" media="screen">
  BODY
  {
    background-color: #FFFFFF;
  }

  #nsr
  {
    padding: 6px 6px 0 6px;
    border-bottom: none;
    vertical-align: top;
    z-index: 2;
    visibility: visible;
    left: 0;
    top: 0;
    position: absolute;
  }

  #mainbody
  {
    left: 0;
    top: 0;
    margin: 0;
    position: absolute;
    padding: 10px;
    overflow: auto;
    height: 100%;
    z-index: 1;
    background-repeat: no-repeat;
    background-position: bottom right;
    background-attachment: fixed;
  }
</style>

<style type="text/css" media="print">
  #nsr
  {
    visibility: none;
  }

  #mainbody
  {
    overflow: visible;
  }
</style>
<script type="text/javascript" language="JavaScript" src="nonscroll.js"></script>

</head>
<body scroll="no">

<div id="page">



        <div id="content">
          <div id="content-inner">
          



  
          <div id="nsr">
            <table border="0" cellspacing="0" cellpadding="4" width="100%">
              <tr valign="top">
                <td align="left">
  


                  <p class="p_Heading1"><span class="f_Heading1">Script Editor</span></p>



  
                </td>
                <td align="right">
                  <a href="introduction.htm" onmouseover="document.images.main.src='button_main_h.gif'" onmouseout="document.images.main.src='button_main.gif'">
                    <img name="main" src="button_main.gif" border=0 alt="Return to Introduction">
                  </a>&nbsp;
    
                  <a href="console_tab.htm" onmouseover="document.images.prev.src='button_prev_h.gif'" onmouseout="document.images.prev.src='button_prev.gif'">
                    <img name=prev src="button_prev.gif" border=0 alt="Previous page" />
                  </a>&nbsp;
    
    
    
                  <a href="theelementbrowser.htm" onmouseover="document.images.next.src='button_next_h.gif'" onmouseout="document.images.next.src='button_next.gif'">
                    <img name=next src="button_next.gif" border=0 alt="Next page" />
                  </a>
    
    
                </td>
              </tr>
            </table>
          </div>
          <div id="mainbody">
  


                <p class="p_BodyText"><span class="f_BodyText">The</span><span class="f_BodyText" style="font-style: italic;"> Script Editor</span><span class="f_BodyText"> enables you to edit scripts. It also contains a toolbar that you can use to run and stop an open script. The editor is based on, and provides the facilities of, the common <a href="code_editors.htm">Code Editor</a>.</span></p>
<p class="p_BodyText"><span class="f_BodyText">To open the Script Editor, double-click on the required script in the </span><span class="f_UIControl">Scripts</span><span class="f_BodyText"> tab of the </span><span class="f_UIControl">Scripter</span><span class="f_BodyText"> window. The editor opens in the main work area.</span></p>
<p class="p_BodyText"><span class="f_BodyText">The VBScript example below is a script that iterates all the packages in the current model and prints their names. </span></p>
<div style="text-align: left; text-indent: 0px; padding: 0px 0px 0px 0px; margin: 5px 0px 5px 13px;"><table cellspacing="0" cellpadding="2" border="0" style="border: none; border-spacing:0px;">
<tr style="text-align:left;vertical-align:bottom;">
<td valign="bottom" width="955" bgcolor="#efeff7" style="width:955px; background-color:#efeff7;"><p class="p_TiporNote" style="border-top: none; border-right: none; border-left: none;"><span class="f_TiporNote">Note:</span></p>
</td>
</tr>
<tr style="text-align:left;">
<td width="955" bgcolor="#f7f7ff" style="width:955px; background-color:#f7f7ff;"><p class="p_TiporNoteText"><span class="f_TiporNoteText">In the example, note the syntax of declaring variables representing Enterprise Architect's script objects. This syntax enables the editor to present <a href="script_editors.htm#Intel">Intellisense</a>, but is not necessary for executing the script.</span></p>
</td>
</tr>
</table>
</div>
<p class="p_TextIndentedL2"><img src="vbsamplescript.png" width="451" height="607" border="0" alt="VBSampleScript"></p>
<p class="p_BodyText"><span class="f_BodyText">The toolbar options enable you to:</span></p>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1">Save changes to the current script</span></li>
<li><span class="f_Bulletlist1">Save the current script under a different name</span></li>
<li><span class="f_Bulletlist1">Run the script</span></li>
<li><span class="f_Bulletlist1">Stop the executing script</span></li>
<li><span class="f_Bulletlist1">View the script output in the </span><span class="f_UIControl">Scripts</span><span class="f_Bulletlist1"> tab of the </span><span class="f_UIControl">Output</span><span class="f_Bulletlist1"> window.</span></li>
</ul>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">Enterprise Architect Script Objects </span></p>
<p class="p_BodyText"><span class="f_BodyText">Enterprise Architect adds to the available functionality and features of the editor script language by providing inbuilt objects. These are either </span><span class="f_BodyText" style="font-style: italic;">Type Libraries</span><span class="f_BodyText">, providing Intellisense for editing purposes, or </span><span class="f_BodyText" style="font-style: italic;">Runtime objects</span><span class="f_BodyText">, providing access to objects of the types described in the Type Libraries. </span></p>
<p class="p_BodyText"><span class="f_BodyText">The available Intellisense scripting objects are:</span></p>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1">EA</span></li>
<li><span class="f_Bulletlist1">MathLib</span></li>
<li><span class="f_Bulletlist1">System</span></li>
<li><span class="f_Bulletlist1">The runtime scripting objects (below).</span></li>
</ul>
<p class="p_BodyText"><span class="f_BodyText">The available runtime scripting objects are:</span></p>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1">Repository [Type: IDualRepository] - this is the Enterprise Architect <a href="theautomationinterface.htm">automation interface</a></span></li>
<li><span class="f_Bulletlist1">Maths [Type: IMath ] </span></li>
<li><span class="f_Bulletlist1">Session [Type: ISession ].</span></li>
</ul>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">Script Editing Intellisense (Required Syntax)</span></p>
<p class="p_BodyText"><a name="intel"></a><span class="f_BodyText">Intellisense is available not only in the Script Editor, but also in the Script Console. Intellisense at its most basic is presented for the inbuilt functionality of the script engine. For Intellisense on the additional Enterprise Architect scripting objects listed above, you must declare variables according to syntax that specifies a type. It is not necessary to use this syntax to execute a script properly. It is only present so that the correct Intellisense can be displayed for an item. The syntax can be seen in the above diagram in, for example:</span></p>
<p class="p_Code"><span class="f_Code">Dim e as EA.Package </span></p>
<p class="p_BodyText"><span class="f_BodyText">Then, when you type, in this case, </span><span class="f_BodyText" style="font-style: italic; font-weight: bold;">e.</span><span class="f_BodyText"> the editor displays a list of member functions and properties of </span><span class="f_BodyText" style="font-style: italic;">e's</span><span class="f_BodyText"> type. </span></p>
<p class="p_TextIndentedL2"><img src="editorsyntax.png" width="207" height="216" border="0" alt="EditorSyntax"></p>
<p class="p_BodyText"><span class="f_BodyText">You select one of these to complete the line of script. You might, therefore, type:</span></p>
<p class="p_Code"><span class="f_Code">VBTrace( e.</span></p>
<p class="p_BodyText"><span class="f_BodyText">As you type the period, the editor presents the appropriate list and you might double-click on, for example, </span><span class="f_MenuKeyField">Abstract</span><span class="f_BodyText">. This is inserted in the line, and you continue to type or select the rest of the statement. In this case, adding the end space and parenthesis.</span></p>
<p class="p_Code"><span class="f_Code">VBTrace( e.Abstract )</span></p>
<p class="p_SubHeadingL2"><span class="f_SubHeadingL2">Keystrokes</span></p>
<p class="p_BodyText"><span class="f_BodyText">In the Script Editor or Console, Intellisense is presented on the following keystrokes. </span></p>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1">Press</span><span class="f_Bulletlist1" style="font-weight: bold;"> .</span><span class="f_Bulletlist1"> (period) after an item to list any members for that item's type. </span></li>
<li><span class="f_Bulletlist1">Press </span><span class="f_MenuKeyField">[Ctrl]</span><span class="f_Bulletlist1">+</span><span class="f_MenuKeyField">[Spacebar]</span><span class="f_Bulletlist1"> on a word to list any Intellisense items with a name starting with the string at the point keystroke was pressed. </span></li>
<li><span class="f_Bulletlist1">Press </span><span class="f_MenuKeyField">[Ctrl]</span><span class="f_Bulletlist1">+</span><span class="f_MenuKeyField">[Spacebar] </span><span class="f_Bulletlist1">when not on a word to display any available top level Intellisense items - these are the Intellisense objects described above plus any built-in methods and properties of the current scripting language. </span></li>
</ul>
<p class="p_Bulletlist1"><span class="f_Bulletlist1">&nbsp;</span></p>




            </div>
          </div>
        </div>



</div>


</body>
</html>
